const logout = document.querySelector('.logout');
const firstMenuList = document.querySelectorAll('.nav>li>a');
const secondMenuList = document.querySelectorAll('.nav ul a');
const initBtn = document.querySelector('.init');
// 请求获取学生信息
// axios.get('/student/list')
//     .then(result => {
//         console.log(result);
//     })
// 退出登录按钮添加事件
logout.addEventListener('click', function () {
    if (confirm('确定退出登录吗？')) {
        localStorage.removeItem('token')
        location.href = './login.html'
    }
})
// 一级菜单点击事件
firstMenuList.forEach(v => {
    v.addEventListener('click', function () {
        // 字体图标的旋转
        v.querySelector('.toggle').classList.toggle('toggleone')
        // 二级菜单的显示
        v.nextElementSibling.classList.toggle('show')
    })
});
// 二级菜单点击事件
secondMenuList.forEach(v => {
    v.addEventListener('click', function () {
        document.querySelector('.nav ul a.active').classList.remove('active')
        v.classList.add('active')
    })
});
// 初始化数据功能
initBtn.addEventListener('click', function () {
    axios.get('/init/data')
        .then(result => {
            if (result.data.code === 0) {
                toastr.success(result.data.message)
            }
        })
})
